package com.ajieee.merge.runner.finance;

import com.ajieee.merge.entity.finance.po.EtfInfoPO;
import com.ajieee.merge.enums.finance.EtlType;
import com.ajieee.merge.enums.finance.Exchange;
import com.ajieee.merge.mapper.EtfInfoMapper;
import com.ajieee.merge.runner.finance.proxy.SseProxy;
import lombok.RequiredArgsConstructor;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 上交所ETF基本信息
 *
 * @author ajieee
 * @date 2025-10-02
 */
@Order(EtlOrder.INFO_ORDER)
@Component
@RequiredArgsConstructor
public class SseEtfInfoEtl extends AbstractEtl {

	private final SseProxy sseProxy;

	private final EtfInfoMapper etfInfoMapper;

	@Override
	public void doExecute() {
		List<EtfInfoPO> sseEtfInfo = sseProxy.getSseEtfInfo();
		etfInfoMapper.deleteByExchange(Exchange.SSE);
		etfInfoMapper.insert(sseEtfInfo);
	}

	@Override
	public EtlType getType() {
		return EtlType.SSE_ETF_INFO;
	}

}
